import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询知识库列表
export function getKnowList(query) {
  return request({
    url: 'know/knowBase/list',
    method: 'get',
    params: query
  })
}

// 查询部门树结构
export function deptTreeSelect(query) {
  return request({
    url: 'system/dept/list',
    method: 'get',
    params: query
  })
}

// 修改知识库信息
export function updateKnow(data) {
  return request({
    url: 'know/knowBase/editfh',
    method: 'post',
    data: data
  })
}

// 删除知识库信息
export function delKnow(data) {
  return request({
    url: 'know/knowBase/removefh',
    method: 'post',
    data: data
  })
}

// 新增知识库信息
export function addKnow(data) {
  return request({
    url: 'know/knowBase/addfh',
    method: 'post',
    data: data
  })
}

// 获取全部人员列表
export function getAllUser(query) {
  return request({
    url: 'system/user/listAll',
    method: 'get',
    params: query
  })
}

// 获取知识库目录
export function getKnowCatalog(data) {
  return request({
    url: 'know/knowBase/getKnowBaseTreefh',
    method: 'post',
    data: data
  })
}

// 获取知识库详情
export function getKnowDetail(data) {
  return request({
    url: 'know/knowBase/getInfofh',
    method: 'post',
    data: data
  })
}

// 获取点赞列表
export function getLikeList(data) {
  return request({
    url: 'know/knowLikeup/listfhNoPage',
    method: 'post',
    data: data
  })
}

// 获取评论列表
export function getCommentList(data) {
  return request({
    url: 'know/knowComment/listfhNoPage',
    method: 'post',
    data: data
  })
}

// 删除评论
export function delComment(data) {
  return request({
    url: 'know/knowComment/removefh',
    method: 'post',
    data: data
  })
}

// 发布评论
export function addComment(data) {
  return request({
    url: 'know/knowComment/addfh',
    method: 'post',
    data: data
  })
}

// 点赞文章
export function addLike(data) {
  return request({
    url: 'know/knowLikeup/addfh',
    method: 'post',
    data: data
  })
}

// 根据参数键名查询参数值
export function upload(file) {
  console.log(file.name)
  var formData = new FormData();
  formData.append('FFILE',file)
  formData.append("annexName", file.name);
  return request({
    url: 'customUploadApplet/formdata/upfileAnnex',
    method: 'post',
    headers:{
      "Content-Type": "multipart/form-data"
    },
    data:formData
  })
}

// 获取知识库前五条数据
export function getKnowledgeList(data) {
  return request({
    url: 'know/knowBase/getKnowBaseTopFive',
    method: 'post',
    data: data
  })
}